package com.extension.company.view.my.localorder.adapter;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.ImageView;

import com.extension.company.admin.R;
import com.extension.company.model.entity.SameCityOrderAllBean;

import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * 同城订单 --所有订单
 */
public class LocalCityAllAdapter extends RecyclerView.Adapter<LocalCityAllAdapter.ViewHolder> {


	private List<SameCityOrderAllBean> list;
	private Context context;
	private OnListFragmentInteractionListener mListener;

	public LocalCityAllAdapter(Context context, List<SameCityOrderAllBean> items) {
		this.context = context;
		list = items;
	}

	@Override
	public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
		View view = LayoutInflater.from(context)
				.inflate(R.layout.my_same_city_order_all_item, parent, false);
		return new ViewHolder(view);
	}

	@Override
	public void onBindViewHolder(final ViewHolder holder, int position) {

		holder.itemLeft.setOnClickListener(new View.OnClickListener() {
			@Override
			public void onClick(View view) {
				mListener.itemLeftBtn();
			}
		});

		holder.itemRight.setOnClickListener(new View.OnClickListener() {
			@Override
			public void onClick(View view) {
				mListener.itemRightBtn();

			}
		});

	}

	@Override
	public int getItemCount() {
		return list.size() == 0 ? 10 : list.size();
	}

	public class ViewHolder extends RecyclerView.ViewHolder {

		@BindView(R.id.all_item_icon)
		ImageView allItemIcon;
		@BindView(R.id.item_left)
		Button itemLeft;
		@BindView(R.id.item_right)
		Button itemRight;

		public ViewHolder(View view) {
			super(view);
			ButterKnife.bind(this, view);

		}
	}

	public interface OnListFragmentInteractionListener {
		void itemLeftBtn();

		void itemRightBtn();
	}

	public void setOnListFragmentListener(OnListFragmentInteractionListener OnListFragmentInteractionListener) {
		this.mListener = OnListFragmentInteractionListener;
	}
}
